import React, { createContext, useImperativeHandle, useState, forwardRef } from 'react'

export const ShareTip = forwardRef((props, ref) => {
    const { tipText = '发送给指定员工或微信群' } = props;
    const [visible, setVisible] = useState(false)

    const show = () => {
        setVisible(true)
    }
    const hide = () => {
        setVisible(false)
    }

    useImperativeHandle(ref, () => ({
        show,
        hide,
    }));

    return (
        <div onClick={hide} className={`share-tip ${visible ? 'show' : 'hide'}`}>
            <div className="tip-content">
                <div className="tip-guide-arrow"></div>
                <div className="tip-info-item">请点击右上角</div>
                <div className="tip-info-item">{tipText}</div>
                <img className="tip-img" src={require("@assets/image/pic_share.png")} />
            </div>
        </div>
    )
})